﻿Option Infer On
Imports System
Imports System.IO
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Navigation
Imports ChatEngine
Partial Public Class SVPageTest
    Delegate Sub Nav()
    Delegate Sub SetContentOfTab(ByVal Header As String, ByVal IsConsoleTab As Boolean)
    Dim tp As TabItem
    Dim CVPage As ServerViewPage
    Dim Frame As Frame
    Public Sub New()
        MyBase.New()
        Me.InitializeComponent()
        newTC.AllowAddNew = False
        CreateTab("#GGASecure", False)
    End Sub
    Private Sub CTabButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

    End Sub
    Public Sub SetFrameContent(Optional ByVal IsConsoleTab As Boolean = False)
        CVPage = New ServerViewPage
        Frame.Content = CVPage
        Frame.Width = tp.Width
        Frame.Height = tp.Height
        CVPage.Width = Frame.Width
        CVPage.Height = Frame.Height
    End Sub
    Private Sub AddTabToContainer()
        tp = New Wpf.Controls.TabItem
        newTC.Items.Add(tp)
    End Sub
    Private Sub SetTabContent(ByVal ChannelName As String, ByVal IsConsoleTab As Boolean)
        Frame = New Frame
        tp.Content = Frame
        tp.Header = ChannelName
        SetFrameContent()
    End Sub
    Public Sub CreateTab(ByVal ChannelName As String, Optional ByVal IsConsoleTab As Boolean = False)
        ' Exit Sub
        newTC.Dispatcher.BeginInvoke(Windows.Threading.DispatcherPriority.Normal, New Nav(AddressOf AddTabToContainer))
        newTC.Dispatcher.BeginInvoke(Windows.Threading.DispatcherPriority.Normal, New SetContentOfTab(AddressOf SetTabContent), ChannelName, IsConsoleTab)
        For I As Integer = 1 To 19745212
        Next
        '     ChatTabs.Dispatcher.BeginInvoke(Windows.Threading.DispatcherPriority.Normal, New SetContentOfTab(AddressOf SetTabContent), ChannelName, IsConsoleTab)
        Dim FindVar As Client.Channel.ChannelItem = SharedVars.Channels.Find(ChannelName)
        If Not FindVar.Name = Nothing Then
            If Not FindVar.ChanObj.TabIsLoaded = True Then
                FindVar.ChanObj.TabIsLoaded = True
            End If
        End If
    End Sub
    Private Sub CreateServerPage_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
        CreateTab("#GGASecure", False)
    End Sub
End Class
